/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package model;

import DataBase.OraConnection;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;

/**
 *
 * @author Asus
 */
public class PengendaliPemeriksaanYudisium {
public static void lihatTabelYudisium(Sekretariat se){
       PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA= new ArrayList<Yudisium>();
       Connection conn = OraConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl","MHS115314020", "MHS115314020");
        java.sql.Statement statement = null;
        try {
            statement = conn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        String sqQ = "select * from yudisium where periode_bulan = '" + se.getBulan() + "' and (periode_tanggal >= " + se.getTanggal_awal() + " and periode_tanggal <= " + se.getTanggal_akhir() + ")";
       ResultSet result = null;
        try {
            result = statement.executeQuery(sqQ);
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (result.next()) {
                Yudisium temp = new Yudisium();
                temp.setNama(result.getString("nama"));
                temp.setNim(result.getString("nim"));
                temp.setNoHp(result.getString("nomor_hp"));
                temp.setProdi(result.getString("prodi"));
                temp.setEmail(result.getString("email"));
                temp.setPeriode(result.getString("periode_bulan"));
                temp.setHari(result.getString("periode_hari"));
                temp.setTanggal(result.getInt("periode_tanggal"));
                temp.setPersetujuan_nilai(result.getString("persetujuan_nilai"));
                temp.setPengesahan_skripsi(result.getString("pengesahan_skripsi"));
                temp.setBebaspinjam_lab(result.getString("bebaspinjam_lab"));
                temp.setBebaspinjam_dosen(result.getString("bebaspinjam_dosen"));
                temp.setBukti_kp(result.getString("bukti_kp"));
                temp.setFotocopy_tkbi(result.getString("fotocopy_tkbi"));
                temp.setFotocopy_ta(result.getString("fotocopy_ta"));
                temp.setSistem_poin(result.getString("sistem_poin"));
                temp.setBukti_rbm(result.getString("bukti_rbm"));
                temp.setStatus(result.getString("status"));
                PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA.add(temp);
            }
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            conn.close();
        } catch (SQLException ex) {
        }
   }
public static void periksaDataYudisium(Periksa pe){
       PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA= new ArrayList<Yudisium>();
       Connection conn = OraConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl","MHS115314020", "MHS115314020");
        java.sql.Statement statement = null;
        try {
            statement = conn.createStatement();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        String sqQ = "select * from yudisium where nim = '" + pe.getNim()+"'";
       ResultSet result = null;
        try {
            result = statement.executeQuery(sqQ);
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            while (result.next()) {
                Yudisium temp = new Yudisium();
                temp.setNama(result.getString("nama"));
                temp.setNim(result.getString("nim"));
                temp.setNoHp(result.getString("nomor_hp"));
                temp.setProdi(result.getString("prodi"));
                temp.setEmail(result.getString("email"));
                temp.setPeriode(result.getString("periode_bulan"));
                temp.setHari(result.getString("periode_hari"));
                temp.setTanggal(result.getInt("periode_tanggal"));
                temp.setPersetujuan_nilai(result.getString("persetujuan_nilai"));
                temp.setPengesahan_skripsi(result.getString("pengesahan_skripsi"));
                temp.setBebaspinjam_lab(result.getString("bebaspinjam_lab"));
                temp.setBebaspinjam_dosen(result.getString("bebaspinjam_dosen"));
                temp.setBukti_kp(result.getString("bukti_kp"));
                temp.setFotocopy_tkbi(result.getString("fotocopy_tkbi"));
                temp.setFotocopy_ta(result.getString("fotocopy_ta"));
                temp.setSistem_poin(result.getString("sistem_poin"));
                temp.setBukti_rbm(result.getString("bukti_rbm"));
                temp.setStatus(result.getString("status"));
                PengendaliPendaftaranYudisium.DAFTAR_MAHASISWA.add(temp);
            }
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPemeriksaanYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        try {
            conn.close();
        } catch (SQLException ex) {
        }
   }
public static void ubahDataYudisium(Yudisium yudisium) {
        Connection conn = OraConnection.open("jdbc:oracle:thin:@172.23.9.185:1521:orcl","MHS115314020", "MHS115314020");
        Statement statement = null;
        try {
            statement = conn.createStatement();
            String sql = "update yudisium set persetujuan_nilai='"+yudisium.getPersetujuan_nilai()+
                    "',pengesahan_skripsi='"+yudisium.getPengesahan_skripsi()+
                    "',bebaspinjam_lab='"+yudisium.getBebaspinjam_lab()+
                    "',bebaspinjam_dosen='"+yudisium.getBebaspinjam_dosen()+
                    "',bukti_kp='"+yudisium.getBukti_kp()+
                    "',fotocopy_tkbi='"+yudisium.getFotocopy_tkbi()+
                    "',fotocopy_ta='"+yudisium.getFotocopy_ta()+
                    "',sistem_poin='"+yudisium.getSistem_poin()+
                    "',bukti_rbm='"+yudisium.getBukti_rbm()+
                    "',status='"+yudisium.getStatus()+"'"+
                    " where nim='"+yudisium.getNim()+"'";
            statement.executeUpdate(sql);
            conn.close();
        } catch (SQLException ex) {
            Logger.getLogger(PengendaliPendaftaranYudisium.class.getName()).log(Level.SEVERE, null, ex);
        }
        JOptionPane.showMessageDialog(null, "Berhasil di update");
    }
}
